/*
 * UserConsultReplyBO.java 
 * 
 * Copyright 2009 Wangfeng Beijing Inc. 
 * All rights reserved. 
 * 
 * Created on 2012-07-06
 */

package com.bjtech.domain.query;

import java.util.Date;
import com.bjtech.web.util.SelectBean;
import org.ssi.web.util.QuerySpecTpl;

/**
 * 功能概述:咨询申诉信息 <br>
 * 
 * @author 王峰
 */

public class UserConsultReplyQuerySpec extends SelectBean {
	/* */
	private Long id;
	/* */
	private Long consult_id;
	/* */
	private String reply_content;
	/* */
	private Date reply_date;
	private Date b_reply_date;
	private Date e_reply_date;

	@Override
	public void queryParamString() {
		StringBuilder fromPart = new StringBuilder(" where 1=1");

		if (this.isAll != null && this.isAll.intValue() != 1) {
			if (QuerySpecTpl.isValid(id)) {
				fromPart.append(" and a.id = ");
				fromPart.append(id);
			}

			if (QuerySpecTpl.isValid(consult_id)) {
				fromPart.append(" and a.consult_id = ");
				fromPart.append(consult_id);
			}

			if (QuerySpecTpl.isValid(reply_content)) {
				fromPart.append(" and a.reply_content like ");
				fromPart.append(" CONCAT('%','");
				fromPart.append(reply_content);
				fromPart.append("','%')");
			}

			if (QuerySpecTpl.isValid(reply_date)) {
				fromPart.append(" and str_to_date(a.reply_date,'%Y-%m-%d')=str_to_date(CONCAT(''',");
				fromPart.append(reply_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(b_reply_date)) {
				fromPart
						.append(" and str_to_date(a.reply_date,'%Y-%m-%d')>=str_to_date(CONCAT(''',");
				fromPart.append(b_reply_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}
			if (QuerySpecTpl.isValid(e_reply_date)) {
				fromPart
						.append(" and str_to_date(a.reply_date,'%Y-%m-%d')<=str_to_date(CONCAT(''',");
				fromPart.append(e_reply_date);
				fromPart.append(",'''),'%Y-%m-%d')");
			}

			if (QuerySpecTpl.isValid(this.direction)
					&& QuerySpecTpl.isValid(this.sort)) {
				fromPart.append(" order by ");
				fromPart.append(this.sort);
				fromPart.append(" ");
				fromPart.append(this.direction);
			} else {
				fromPart.append(" order by ");
				fromPart.append("id");
				fromPart.append(" ");
				fromPart.append("asc");

			}
		}
		super.setQueryString(fromPart.toString());
	}

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getConsult_id() {
		return this.consult_id;
	}

	public void setConsult_id(Long consult_id) {
		this.consult_id = consult_id;
	}

	public String getReply_content() {
		return this.reply_content;
	}

	public void setReply_content(String reply_content) {
		this.reply_content = reply_content;
	}

	public Date getReply_date() {
		return this.reply_date;
	}

	public void setReply_date(Date reply_date) {
		this.reply_date = reply_date;
	}

	public Date getB_reply_date() {
		return this.b_reply_date;
	}

	public void setB_reply_date(Date b_reply_date) {
		this.b_reply_date = b_reply_date;
	}

	public Date getE_reply_date() {
		return this.e_reply_date;
	}

	public void setE_reply_date(Date e_reply_date) {
		this.e_reply_date = e_reply_date;
	}
}
